<form class="layui-form layui-form-pane" method="post" action="{{url('admin/attrkey/insert')}}"  >
    <div class="layui-form-item">
        <label class="layui-form-label">规格类型</label>
        <div class="layui-input-inline">
            <input type="text" name="kname" required  lay-verify="required" placeholder="请输入规格类型" autocomplete="off" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
 
<script>
   //Demo
    layui.use('form', function(){
        var form = layui.form;
        form.render();
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.confirm('确认执行此操作？', {icon: 3, title:'提示'}, function(index){
                ajax("{{url('admin/attrkey/insert')}}",data.field,function(data){
                    layer.close();
                    layer.closeAll();
                    layer.msg(data.msg);
                    if(data.code == 1){
                        location.href = location.href;
                    }
                });
            });
            return false;
        });
    });
    
</script>